package com.yiqi.zhiyuan.feature.login.view;

import android.os.Bundle;
import android.support.v7.widget.Toolbar;
import android.text.Html;
import android.widget.TextView;

import com.suozhang.framework.component.http.RxDataProcessFactory;
import com.suozhang.framework.framework.AM;
import com.suozhang.framework.framework.BaseActivity;
import com.yiqi.zhiyuan.R;
import com.yiqi.zhiyuan.entity.vo.TextVO;
import com.yiqi.zhiyuan.framework.api.UserApi;

import butterknife.BindView;
import butterknife.ButterKnife;
import io.reactivex.Observer;
import io.reactivex.disposables.Disposable;

public class RegistrationAgreementActivity extends BaseActivity {

    @BindView(R.id.toolbar)
    Toolbar toolbar;
    @BindView(R.id.tv_about)
    TextView tvAbout;


    @Override
    protected int attachLayoutRes() {
        return R.layout.activity_registration_agreement;
    }

    @Override
    protected void initView() {
        super.initView();
        initToolBar(toolbar, "", true, true);
    }

    @Override
    protected void initInjector() {

    }

    @Override
    protected void initData() {


        AM.api().createApiService(UserApi.class)
                .registrationAgreement()
                .compose(RxDataProcessFactory.dataPrepAndIoToMainTransformer())
                .subscribe(new Observer<TextVO>() {
                    @Override
                    public void onSubscribe(Disposable d) {

                    }

                    @Override
                    public void onNext(TextVO textVO) {
                        initToolBar(toolbar, textVO.getTitle(), true, true);
                        tvAbout.setText(Html.fromHtml(textVO.getContent()));

                    }

                    @Override
                    public void onError(Throwable e) {
                         showMsg(e.getMessage());
                    }

                    @Override
                    public void onComplete() {

                    }
                });


    }

}
